<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>线程池监控信息</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">修改线程池参数</h4>
            </div>
            <div class="modal-body">
                <form role="form">
                    <div class="form-group">
                        <label for="coreSize">核心线程数</label>
                        <input type="text" class="form-control" id="coreSize" placeholder="核心线程数">
                    </div>
                    <div class="form-group">
                        <label for="maxPoolSize">最大线程数</label>
                        <input type="text" class="form-control" id="maxPoolSize" placeholder="最大线程数">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" onclick="submit_edit()" class="btn btn-primary">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<table class="table table-striped">
   <thead>
       <tr>
           <th>应用名称</th>
           <th>线程池名称</th>
           <th>核心线程数</th>
           <th>最大线程数</th>
           <th>活跃线程数</th>
           <th>队列类型</th>
           <th>队列大小</th>
           <th>队列剩余空间</th>
           <th>操作</th>
       </tr>
   </thead>
    <tbody>
        <tr th:each="threadPoolConfig:${threadPoolConfigEntityList}">
            <td th:text="${threadPoolConfig.applicationName}"></td>
            <td th:text="${threadPoolConfig.threadPoolName}"></td>
            <td th:text="${threadPoolConfig.corePoolSize}"></td>
            <td th:text="${threadPoolConfig.maxPoolSize}"></td>
            <td th:text="${threadPoolConfig.activeCount}"></td>
            <td th:text="${threadPoolConfig.queueType}"></td>
            <td th:text="${threadPoolConfig.queueSize}"></td>
            <td th:text="${threadPoolConfig.queueRemainSize}"></td>
            <td><a class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">修改</a></td>
        </tr>
    </tbody>
</table>
</body>

<script>

    function showEditModal(){
        $('#myModal').modal('myModal');
    }

    function submit_edit(){
        console.log($('#maxPoolSize').val())
        $.ajax({
            type: 'POST',
            url:'/monitor/thread/pool/config',
            dataType: 'json',
            data : JSON.stringify({corePoolSize: $("#coreSize").val(), maxPoolSize: $("#maxPoolSize").val()}),
            contentType: 'application/json',
            success: function (res){
                console.log(res)
            }
        })
    }

</script>
</html>